<template>
  <div style="width: 100%;height: 100%;">
    <div class="barChart" ref="barChart"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      myChart: null,
      chartOptions: {
        color: ["#2f89cf"],
        //表格大小
        grid: {
          left: "0%",
          top: "10px",
          right: "0%",
          bottom: "4%",
          containLabel: true,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效,影子效果
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        xAxis: [
          {
            type: "category",
            data: [
              "动作片",
              "动画片",
              "电视剧",
              "纪录片",
              "综艺片",
              "伦理片",
              "恐怖片",
            ],
            axisTick: {
              alignWithLabel: true,
            },
            axisLabel: {
              color: "rgba(255,255,255,.6)",
              fontSize: "12",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            axisLabel: {
              color: "rgba(255,255,255,.6)",
              fontSize: "12",
            },
            lineStyle: {
              color: "rgba(255,255,255,.1)",
              width: 1,
              type: "solid",
            },
            splitLine: {
              lineStyle: {
                color: "rgba(255,255,255,.1)",
              },
            },
          },
        ],
        series: [
          {
            name: "直接访问",
            type: "bar",
            barWidth: "60%",
            data: [10, 52, 200, 334, 390, 330, 220],
          },
        ],
      },
    };
  },
  mounted() {
    this.createEchart();
  },
  methods: {
    createEchart() {
      this.myChart = this.$echarts
        .init(this.$refs.barChart)
        .setOption(this.chartOptions);
      window.addEventListener("resize", () => {
        this.myChart.resize();
      });
    },
  },
};
</script>
<style lang="less" scoped>
.barChart {
  width: 100%;
  height: 100%;
}
</style>
